<template>
  <div>
    <ul>
      <li v-for="(item, index) in arr" :key="index">
        {{ item }} <button @click="del(index)">删除</button>
      </li>
      <br />
      <button @click="addLI">添加</button>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [1],
    };
  },
  methods: {
    addLI() {
      let count = Math.floor(Math.random() * 100);
      console.log(+count);
      this.arr.push(+count);
    },
    del(index) {
      this.arr.splice(index, 1);
    },
  },
};
</script>

<style>
</style>